﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Interactivity;
using Microsoft.Phone.Controls;

namespace PhoneToolkit.Extensions.Behaviors
{
    public class TransitionSlideOutBehavior : Behavior<PhoneApplicationPage>
    {
        protected override void OnAttached()
        {
            base.OnAttached();

            NavigationOutTransition navOutTrans = new NavigationOutTransition();
            navOutTrans.Backward = new SlideTransition() { Mode = TransitionModeBackwardOut };
            navOutTrans.Forward = new SlideTransition() { Mode = TransitionModeForwardOut };
            TransitionService.SetNavigationOutTransition(this.AssociatedObject, navOutTrans);
        }

        protected override void OnDetaching()
        {
            base.OnDetaching();
        }

        public static readonly DependencyProperty TransitionModeBackwardOutProperty = DependencyProperty.Register("TransitionModeSlideBackWardOut", typeof(SlideTransitionMode), typeof(TransitionSlideOutBehavior), new PropertyMetadata(SlideTransitionMode.SlideRightFadeOut));
        public static readonly DependencyProperty TransitionModeForwardOutProperty = DependencyProperty.Register("TransitionModeSlideForwardOut", typeof(SlideTransitionMode), typeof(TransitionSlideOutBehavior), new PropertyMetadata(SlideTransitionMode.SlideLeftFadeOut));

        public SlideTransitionMode TransitionModeBackwardOut
        {
            get { return (SlideTransitionMode)GetValue(TransitionModeBackwardOutProperty); }
            set { SetValue(TransitionModeBackwardOutProperty, value); }
        }

        public SlideTransitionMode TransitionModeForwardOut
        {
            get { return (SlideTransitionMode)GetValue(TransitionModeForwardOutProperty); }
            set { SetValue(TransitionModeForwardOutProperty, value); }
        }
    }
}
